package com.mowh.gof23.structural.patterns.bridge;

/**
 * @author mowh1gd
 * @create 2023/10/25 8:04
 */
public class StringDisplayImpl extends DisplayImpl{
    private String aString;
    private int width;

    public StringDisplayImpl(String aString) {
        this.aString = aString;
        this.width = aString.getBytes().length;
    }

    @Override
    public void rawOpen() {
        printLine();
    }

    @Override
    public void rawPrint() {
        System.out.println("|" + aString + "|");
    }

    @Override
    public void rawClose() {
        printLine();
    }
    private void printLine() {
        System.out.print("+");
        for (int i = 0; i < width; i++) {
            System.out.print("-");
        }
        System.out.println("+");
    }
}
